home *** CD-ROM | disk | FTP | other *** search
/ Enter 2006 September / Enter 09 2006.iso / Internet / SpamExperts Home 1.1 / SpamExperts Home.exe / lib / spamexperts.modules / spamexperts / LSPControl.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2006-07-14  |  2.9 KB  |  72 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. """
  5. This module contains code to manage and control the 
  6. installed LSP for SpamExperts. Installing the LSP means
  7. turning it on using a commandline tool called 'RegisterLSP'.
  8. The LSP code is a dll in 'WINDOWS\\SYSTEM32' called 'SpamExpertsLSP.dll'
  9. Configuration is done with a file 'SpamExpertsLSP.ini in the same system
  10. directory.
  11. """
  12. import os
  13. import sys
  14. import subprocess
  15. import win32con
  16. from spamexperts import resources
  17.  
  18. class LSPControl(object):
  19.     lib_dir = os.path.join(resources.application_directory(), 'lib')
  20.     
  21.     def installLSP(self):
  22.         if self.isInstalled():
  23.             return None
  24.         
  25.         platform = sys.getwindowsversion()[3]
  26.         if platform == win32con.VER_PLATFORM_WIN32_WINDOWS:
  27.             subprocess.call('RegisterLSP.exe -g -z MS.w95.spi.tcp -z MS.w95.spi.udp -y', shell = True, stdin = subprocess.PIPE, stderr = subprocess.PIPE, stdout = subprocess.PIPE, cwd = self.lib_dir)
  28.         elif platform == win32con.VER_PLATFORM_WIN32_NT:
  29.             subprocess.call('RegisterLSP.exe -g -z MSAFD Tcpip [TCP/IP] -z MSAFD Tcpip [UDP/IP] -y', shell = True, cwd = self.lib_dir)
  30.         else:
  31.             print >>sys.stderr, 'Unsupported Windows version for transparent proxy.'
  32.  
  33.     
  34.     def removeLSP(self):
  35.         if not self.isInstalled():
  36.             return None
  37.         
  38.         subprocess.call('RegisterLSP.exe -q SpamExpertsLSP', stdin = subprocess.PIPE, stderr = subprocess.PIPE, stdout = subprocess.PIPE, shell = True, cwd = self.lib_dir)
  39.  
  40.     
  41.     def getLSPInfo(self):
  42.         return subprocess.Popen('RegisterLSP.exe -p', shell = True, cwd = self.lib_dir, stdin = subprocess.PIPE, stderr = subprocess.PIPE, stdout = subprocess.PIPE).stdout.read()
  43.  
  44.     
  45.     def getLSPShortInfo(self):
  46.         
  47.         try:
  48.             return subprocess.Popen('RegisterLSP.exe -l', shell = True, cwd = self.lib_dir, stdin = subprocess.PIPE, stderr = subprocess.PIPE, stdout = subprocess.PIPE).stdout.read()
  49.         except WindowsError:
  50.             e = None
  51.             print >>sys.stderr, 'Could not check LSP status', str(e)
  52.             return ''
  53.  
  54.  
  55.     
  56.     def isInstalled(self):
  57.         o = self.getLSPShortInfo()
  58.         for l in o.split('\n'):
  59.             
  60.             try:
  61.                 (catid, sep, name) = l.split()
  62.             except ValueError:
  63.                 continue
  64.  
  65.             if name == 'SpamExpertsLSP':
  66.                 return True
  67.                 continue
  68.         
  69.         return False
  70.  
  71.  
  72.